export default {
  name: "OnlineComponent",
  components: {
    check: () => import("../../../socical/socialCheck/check.vue"),
    cityCascader: () => import("../../../../component/cityCascader/index.vue")
  },
  data() {
    return {
      addressOptions: [],
      company: {
        name: "",
        createTime: [],
        begintime: "",
        endtime: "",
        region: "",
        citys: [],
        province: "", //省份编码
        city: "", //城市编码
        area: "" //区域编码
      },
      level: "0",
      OnLinePlayCash: [{
        ordernum: "",
        companyname: "",
        totalfee: "",
        rechargdate: "",
        paytype: ""
      }],
      Online: {
        total: 15,
        pageNum: 1,
        pageSize: 10
      },
      loading: false,
      checkFlag: false,
      companyname: "",
      companyid: "",
      moneyTypes: [{
          title: "充值总金额",
          total: 0
        },
        {
          title: "PC端充值总额",
          total: 0
        },
        {
          title: "Android端充值总额",
          total: 0
        },
        {
          title: "iphone充值总额",
          total: 0
        }
      ],
      moneyTypeTotal: {}
    }
  },
  created() {
    this.getAuthority()
  },
  mounted() {

    this.getOnlineData()
  },
  methods: {
    getAuthority() {
      let userinfo = localStorage.getItem('userinfo');
      userinfo = JSON.parse(userinfo);
      this.level = userinfo.level;
      this.company.province = +userinfo.province || '';
      this.company.city = +userinfo.city || '';
      this.company.area = +userinfo.area || '';
      this.company.citys = [];
      this.company.citys.push(+userinfo.province);
      this.company.citys.push(+userinfo.city);
      this.company.citys.push(+userinfo.area);
    },


    getOnlineData() {
      if (this.company.begintime && this.company.endtime && Date.parse(this.company.begintime) > Date.parse(this.company.endtime)) {
        this.$message({
          message: "结束时间不能早于开始时间",
          type: "warning"
        });
        return;
      }
      this.loading = true
      // if (this.company.begintime && this.company.endtime) {
      //   // this.company.begintime = this.company.createTime[0]
      //   // this.company.endtime = this.company.createTime[1]
      // } else {
      //   this.company.begintime = ""
      //   this.company.endtime = ""
      // }
      let obj = {
        companyname: this.company.name,
        begintime: this.company.begintime,
        endtime: this.company.endtime,
        pagenum: this.Online.pageNum,
        pagesize: this.Online.pageSize,
        province: this.company.province, //省份编码
        city: this.company.city, //城市编码
        area: this.company.area //区域编码
      }
      this.$axios
        .post("/app/v1/platform/recharge/onlineList", obj)
        .then(resp => {
			console.log(resp);
          if (resp.data.message === "success.") {
            this.OnLinePlayCash = resp.data.data.list
			console.log(1)
            this.Online.total = parseInt(resp.data.data.totalnum)
            this.moneyTypes[0].total = resp.data.data.totalsum || 0
            this.moneyTypes[1].total = resp.data.data.pcsum || 0
            this.moneyTypes[2].total = resp.data.data.androidsum || 0
            this.moneyTypes[3].total = resp.data.data.applesum || 0
            this.loading = false
          }
        })
    },
    SearchInfo() {
      this.Online.pageNum = 1
      this.getOnlineData()
    },
    //线上充值记录分页查询
    OnlineCurrentChange(val) {
      this.Online.pageNum = val
      this.getOnlineData()
    },
    showCompanyInfo(row) {
		console.log(row);
      this.companyid = row.companyid
      this.companyname = row.companyname
      this.checkFlag = true
    },
    changeCity() {
      this.form.company.regions = this.regions[this.regions.length - 1]
    },
    handleSizeChange(val) {
      this.Online.pageSize = val
      this.getOnlineData()
    },
    // 选择城市
    handleCityChange(val) {
      this.company.citys = val
      this.company.province = val[0]
      this.company.city = val[1]
      this.company.area = val[2]
    }
  }
}